/**
 * 
 */
package edu.arizona.eller.mis.liferoulette.utils;

import android.app.Activity;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

/**
 * @author Blaine Boule - blaineb@email.arizona.edu
 *
 */
public class ConnectionUtils {
	private static ConnectionUtils _INSTANCE = null;
	private ConnectionUtils(){}
	
	public static ConnectionUtils getInstance(){
		if(_INSTANCE == null){
			_INSTANCE = new ConnectionUtils();
		}
		return _INSTANCE;
	}
	
	public boolean isNetworkAvailable(Activity activity){
		ConnectivityManager cm = (ConnectivityManager) activity.getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo ni = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
		boolean isWifiConn = ni.isConnected();
		ni = cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
		boolean isMobileConn = ni.isConnected();
		
		return (isMobileConn || isWifiConn);
	}
}
